{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a8b892c8",
   "metadata": {},
   "source": [
    "Printed and electronic copies of *Modeling and Simulation in Python* are available from [No Starch Press](https://nostarch.com/modeling-and-simulation-python) and [Bookshop.org](https://bookshop.org/p/books/modeling-and-simulation-in-python-allen-b-downey/17836697?ean=9781718502161) and [Amazon](https://amzn.to/3y9UxNb)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "pressing-munich",
   "metadata": {},
   "source": [
    "# Epidemiology"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "imported-table",
   "metadata": {
    "tags": []
   },
   "source": [
    "*Modeling and Simulation in Python*\n",
    "\n",
    "Copyright 2021 Allen Downey\n",
    "\n",
    "License: [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-nc-sa/4.0/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "electoral-turkey",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# install Pint if necessary\n",
    "\n",
    "try:\n",
    "    import pint\n",
    "except ImportError:\n",
    "    !pip install pint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "formal-context",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# download modsim.py if necessary\n",
    "\n",
    "from os.path import basename, exists\n",
    "\n",
    "def download(url):\n",
    "    filename = basename(url)\n",
    "    if not exists(filename):\n",
    "        from urllib.request import urlretrieve\n",
    "        local, _ = urlretrieve(url, filename)\n",
    "        print('Downloaded ' + local)\n",
    "    \n",
    "download('https://raw.githubusercontent.com/AllenDowney/' +\n",
    "         'ModSimPy/master/modsim.py')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "progressive-typing",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# import functions from modsim\n",
    "\n",
    "from modsim import *"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "persistent-carbon",
   "metadata": {},
   "source": [
    "In this chapter, we'll develop a model of an epidemic as it spreads in a\n",
    "susceptible population, and use it to evaluate the effectiveness of\n",
    "possible interventions.\n",
    "\n",
    "My presentation of the model in the next few chapters is based on an excellent article by David Smith and Lang Moore, \"The SIR Model for Spread of Disease,\" *Journal of Online Mathematics and its Applications*, December 2001, available at <http://modsimpy.com/sir>."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "working-patent",
   "metadata": {},
   "source": [
    "## The Freshman Plague\n",
    "\n",
    "Every year at Olin College, about 90 new students come to campus from\n",
    "around the country and the world. Most of them arrive healthy and happy, but usually at least one brings with them some kind of infectious disease. A few weeks later, predictably, some fraction of the incoming class comes down with what we call the \"Freshman Plague\".\n",
    "\n",
    "In this chapter we introduce a well-known model of infectious disease,\n",
    "the Kermack-McKendrick model, and use it to explain the progression of\n",
    "the disease over the course of the semester, predict the effect of\n",
    "possible interventions (like immunization) and design the most effective intervention campaign.\n",
    "\n",
    "So far we have done our own modeling; that is, we've chosen physical\n",
    "systems, identified factors that seem important, and made decisions\n",
    "about how to represent them. In this chapter we start with an existing\n",
    "model and reverse-engineer it. Along the way, we consider the modeling\n",
    "decisions that went into it and identify its capabilities and\n",
    "limitations."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "distant-expense",
   "metadata": {},
   "source": [
    "## The Kermack-McKendrick Model\n",
    "\n",
    "The Kermack-McKendrick (KM) model is an example of an *SIR model*,\n",
    "so-named because it represents three categories of people:\n",
    "\n",
    "-   *S*: People who are \"susceptible\", that is, capable of\n",
    "    contracting the disease if they come into contact with someone who\n",
    "    is infected.\n",
    "\n",
    "-   *I*: People who are \"infectious\", that is, capable of passing\n",
    "    along the disease if they come into contact with someone\n",
    "    susceptible.\n",
    "\n",
    "-   *R*: People who are \"recovered\". In the basic version of the\n",
    "    model, people who have recovered are considered to be no longer\n",
    "    infectious and immune to reinfection. That is a reasonable model for some diseases, but not for others, so it should be on the list of assumptions to reconsider later."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "reasonable-kitchen",
   "metadata": {},
   "source": [
    "Let's think about how the number of people in each category changes over time. Suppose we know that people with the disease are infectious for a period of 4 days, on average.\n",
    "If 100 people are infectious at a particular point in time, and we ignore the particular time each one became infected, we expect about 1 out of 4 to recover on any particular day.\n",
    "\n",
    "Putting that a different way, if the time between recoveries is 4 days, the recovery rate is about 0.25 recoveries per day, which we'll denote with the Greek letter gamma, $\\gamma$, or the variable name `gamma`.\n",
    "\n",
    "If the total number of people in the population is $N$, and the fraction currently infectious is $i$, the total number of recoveries we expect per day is $\\gamma i N$."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "important-yugoslavia",
   "metadata": {},
   "source": [
    "Now let's think about the number of new infections. Suppose we know that each susceptible person comes into contact with 1 person every 3 days, on average, in a way that would cause them to become infected if the other person is infected. We'll denote this contact rate with the Greek letter beta, $\\beta$, or the variables name `beta`.\n",
    "\n",
    "It's probably not reasonable to assume that we know $\\beta$ ahead of\n",
    "time, but later we'll see how to estimate it based on data from previous outbreaks.\n",
    "\n",
    "If $s$ is the fraction of the population that's susceptible, $s N$ is\n",
    "the number of susceptible people, $\\beta s N$ is the number of contacts per day, and $\\beta s i N$ is the number of those contacts where the other person is infectious."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "virgin-cambodia",
   "metadata": {},
   "source": [
    "In summary:\n",
    "\n",
    "-   The number of recoveries we expect per day is $\\gamma i N$; dividing by $N$ yields the fraction of the population that recovers in a day, which is $\\gamma i$.\n",
    "\n",
    "-   The number of new infections we expect per day is $\\beta s i N$; dividing by $N$ yields the fraction of the population that gets infected in a day, which is $\\beta s i$.\n",
    "\n",
    "The KM model assumes that the population is closed; that is, no one\n",
    "arrives or departs, so the size of the population, $N$, is constant."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "accomplished-franklin",
   "metadata": {},
   "source": [
    "## The KM Equations\n",
    "\n",
    "If we treat time as a continuous quantity, we can write differential\n",
    "equations that describe the rates of change for $s$, $i$, and $r$ (where $r$ is the fraction of the population that has recovered):\n",
    "\n",
    "$$\\begin{aligned}\n",
    "\\frac{ds}{dt} &= -\\beta s i \\\\\n",
    "\\frac{di}{dt} &= \\beta s i - \\gamma i\\\\\n",
    "\\frac{dr}{dt} &= \\gamma i\\end{aligned}$$ \n",
    "\n",
    "To avoid cluttering the equations, I leave it implied that $s$ is a function of time, $s(t)$, and likewise for $i$ and $r$.\n",
    "\n",
    "SIR models are examples of *compartment models*, so-called because\n",
    "they divide the world into discrete categories, or compartments, and\n",
    "describe transitions from one compartment to another. Compartments are\n",
    "also called *stocks* and transitions between them are called\n",
    "*flows*.\n",
    "\n",
    "In this example, there are three stocks---susceptible, infectious, and\n",
    "recovered---and two flows---new infections and recoveries. Compartment\n",
    "models are often represented visually using stock and flow diagrams (see <http://modsimpy.com/stock>)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fourth-celtic",
   "metadata": {},
   "source": [
    "The following figure shows the stock and flow diagram for the KM model.\n",
    "\n",
    "![Stock and flow diagram for an SIR\n",
    "model.](https://github.com/AllenDowney/ModSim/raw/main/figs/stock_flow1.png)\n",
    "\n",
    "Stocks are represented by rectangles, flows by arrows. The widget in the middle of the arrows represents a valve that controls the rate of flow; the diagram shows the parameters that control the valves."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "martial-details",
   "metadata": {},
   "source": [
    "## Implementing the KM model\n",
    "\n",
    "For a given physical system, there are many possible models, and for a\n",
    "given model, there are many ways to represent it. For example, we can\n",
    "represent an SIR model as a stock-and-flow diagram, as a set of\n",
    "differential equations, or as a Python program. The process of\n",
    "representing a model in these forms is called *implementation*. In\n",
    "this section, we implement the KM model in Python.\n",
    "\n",
    "I'll represent the initial state of the system using a `State` object\n",
    "with state variables `s`, `i`, and `r`; they represent the fraction of\n",
    "the population in each compartment.\n",
    "\n",
    "We can initialize the `State` object with the *number* of people in each compartment; for example, here is the initial state with one infected student in a class of 90:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "criminal-change",
   "metadata": {},
   "outputs": [],
   "source": [
    "init = State(s=89, i=1, r=0)\n",
    "show(init)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "chronic-jonathan",
   "metadata": {},
   "source": [
    "We can convert the numbers to fractions by dividing by the total:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "pediatric-ratio",
   "metadata": {},
   "outputs": [],
   "source": [
    "init /= init.sum()\n",
    "show(init)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ordinary-scottish",
   "metadata": {},
   "source": [
    "For now, let's assume we know the time between contacts and time between\n",
    "recoveries:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "little-stylus",
   "metadata": {},
   "outputs": [],
   "source": [
    "tc = 3             # time between contacts in days \n",
    "tr = 4             # recovery time in days"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "covered-avenue",
   "metadata": {},
   "source": [
    "We can use them to compute the parameters of the model:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "veterinary-aerospace",
   "metadata": {},
   "outputs": [],
   "source": [
    "beta = 1 / tc      # contact rate in per day\n",
    "gamma = 1 / tr     # recovery rate in per day"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "lightweight-delta",
   "metadata": {},
   "source": [
    "I'll use a `System` object to store the parameters and initial\n",
    "conditions. The following function takes the system parameters and returns a new `System` object:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "nasty-sherman",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "def make_system(beta, gamma):\n",
    "    init = State(s=89, i=1, r=0)\n",
    "    init /= init.sum()\n",
    "\n",
    "    return System(init=init, t_end=7*14,\n",
    "                  beta=beta, gamma=gamma)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "victorian-blogger",
   "metadata": {},
   "source": [
    "The default value for `t_end` is 14 weeks, about the length of a\n",
    "semester.\n",
    "\n",
    "Here's what the `System` object looks like. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "supported-shadow",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "system = make_system(beta, gamma)\n",
    "show(system)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "requested-turning",
   "metadata": {},
   "source": [
    "Now that we have object to represent the system and its state, we are ready for the update function."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "alone-desire",
   "metadata": {},
   "source": [
    "## The Update Function\n",
    "\n",
    "The purpose of an update function is to take the current state of a system and compute the state during the next time step.\n",
    "Here's the update function we'll use for the KM model:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "wound-wayne",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "def update_func(t, state, system):\n",
    "    s, i, r = state.s, state.i, state.r\n",
    "\n",
    "    infected = system.beta * i * s    \n",
    "    recovered = system.gamma * i\n",
    "    \n",
    "    s -= infected\n",
    "    i += infected - recovered\n",
    "    r += recovered\n",
    "    \n",
    "    return State(s=s, i=i, r=r)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aboriginal-malpractice",
   "metadata": {},
   "source": [
    "`update_func` takes as parameters the current time, a `State` object, and a `System` object.\n",
    "\n",
    "The first line unpacks the `State` object, assigning the values of the state variables to new variables with the same names.\n",
    "This is an example of *multiple assignment*.\n",
    "The left side is a sequence of variables; the right side is a sequence of expressions.\n",
    "The values on the right side are assigned to the variables on the left side, in order.\n",
    "By creating these variables, we avoid repeating `state` several times, which makes the code easier to read.\n",
    "\n",
    "The update function computes `infected` and `recovered` as a fraction of the population, then updates `s`, `i` and `r`. The return value is a `State` that contains the updated values.\n",
    "\n",
    "We can call `update_func` like this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "assigned-feelings",
   "metadata": {},
   "outputs": [],
   "source": [
    "state = update_func(0, init, system)\n",
    "show(state)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "standard-search",
   "metadata": {},
   "source": [
    "The result is the new `State` object.\n",
    "\n",
    "You might notice that this version of `update_func` does not use one of its parameters, `t`. I include it anyway because update functions\n",
    "sometimes depend on time, and it is convenient if they all take the same parameters, whether they need them or not."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "informational-cisco",
   "metadata": {},
   "source": [
    "## Running the Simulation\n",
    "\n",
    "Now we can simulate the model over a sequence of time steps:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "occasional-pottery",
   "metadata": {},
   "outputs": [],
   "source": [
    "def run_simulation1(system, update_func):\n",
    "    state = system.init\n",
    "\n",
    "    for t in range(0, system.t_end):\n",
    "        state = update_func(t, state, system)\n",
    "\n",
    "    return state"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fifteen-metallic",
   "metadata": {},
   "source": [
    "The parameters of `run_simulation` are the `System` object and the\n",
    "update function. The `System` object contains the parameters, initial\n",
    "conditions, and values of `0` and `t_end`.\n",
    "\n",
    "We can call `run_simulation` like this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "differential-difference",
   "metadata": {},
   "outputs": [],
   "source": [
    "final_state = run_simulation1(system, update_func)\n",
    "show(final_state)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "behind-removal",
   "metadata": {},
   "source": [
    "The result indicates that after 14 weeks (98 days), about 52% of the\n",
    "population is still susceptible, which means they were never infected,\n",
    "almost 48% have recovered, which means they were infected at some point, and less than 1% are actively infected."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "serial-genius",
   "metadata": {},
   "source": [
    "## Collecting the Results\n",
    "\n",
    "The previous version of `run_simulation` returns only the final state,\n",
    "but we might want to see how the state changes over time. We'll consider two ways to do that: first, using three `TimeSeries` objects, then using a new object called a `TimeFrame`.\n",
    "\n",
    "Here's the first version:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "advanced-recommendation",
   "metadata": {},
   "outputs": [],
   "source": [
    "def run_simulation2(system, update_func):\n",
    "    S = TimeSeries()\n",
    "    I = TimeSeries()\n",
    "    R = TimeSeries()\n",
    "\n",
    "    state = system.init\n",
    "    S[0], I[0], R[0] = state\n",
    "    \n",
    "    for t in range(0, system.t_end):\n",
    "        state = update_func(t, state, system)\n",
    "        S[t+1], I[t+1], R[t+1] = state.s, state.i, state.r\n",
    "    \n",
    "    return S, I, R"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "behind-breathing",
   "metadata": {},
   "source": [
    "First, we create `TimeSeries` objects to store the results.\n",
    "Next we initialize `state` and the first elements of `S`, `I` and\n",
    "`R`.\n",
    "\n",
    "Inside the loop, we use `update_func` to compute the state of the system at the next time step, then use multiple assignment to unpack the elements of `state`, assigning each to the corresponding `TimeSeries`.\n",
    "\n",
    "At the end of the function, we return the values `S`, `I`, and `R`. This is the first example we have seen where a function returns more than one value.\n",
    "\n",
    "We can run the function like this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "subtle-zambia",
   "metadata": {},
   "outputs": [],
   "source": [
    "S, I, R = run_simulation2(system, update_func)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "smoking-toddler",
   "metadata": {},
   "source": [
    "We'll use the following function to plot the results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "welcome-tractor",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "def plot_results(S, I, R):\n",
    "    S.plot(style='--', label='Susceptible')\n",
    "    I.plot(style='-', label='Infected')\n",
    "    R.plot(style=':', label='Recovered')\n",
    "    decorate(xlabel='Time (days)',\n",
    "             ylabel='Fraction of population')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "important-command",
   "metadata": {},
   "source": [
    "And run it like this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "agricultural-joining",
   "metadata": {},
   "outputs": [],
   "source": [
    "plot_results(S, I, R)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "civic-pharmacy",
   "metadata": {},
   "source": [
    "It takes about three weeks (21 days) for the outbreak to get going, and about five weeks (35 days) to peak. The fraction of the population that's infected is never very high, but it adds up. In total, almost half the population gets sick."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "unexpected-empire",
   "metadata": {},
   "source": [
    "## Now With a TimeFrame\n",
    "\n",
    "If the number of state variables is small, storing them as separate\n",
    "`TimeSeries` objects might not be so bad. But a better alternative is to use a `TimeFrame`, which is another object defined in the ModSim\n",
    "library.\n",
    "A `TimeFrame` is a kind of a `DataFrame`, which we used earlier to store world population estimates.\n",
    "\n",
    "Here's a more concise version of `run_simulation` using a `TimeFrame`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "native-central",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "def run_simulation(system, update_func):\n",
    "    frame = TimeFrame(columns=system.init.index)\n",
    "    frame.loc[0] = system.init\n",
    "    \n",
    "    for t in range(0, system.t_end):\n",
    "        frame.loc[t+1] = update_func(t, frame.loc[t], system)\n",
    "    \n",
    "    return frame"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "beginning-secret",
   "metadata": {},
   "source": [
    "The first line creates an empty `TimeFrame` with one column for each\n",
    "state variable. Then, before the loop starts, we store the initial\n",
    "conditions in the `TimeFrame` at `0`. Based on the way we've been using\n",
    "`TimeSeries` objects, it is tempting to write:\n",
    "\n",
    "```\n",
    "frame[0] = system.init\n",
    "```\n",
    "\n",
    "But when you use the bracket operator with a `TimeFrame` or `DataFrame`, it selects a column, not a row. \n",
    "To select a row, we have to use `loc`, like this:\n",
    "\n",
    "```\n",
    "frame.loc[0] = system.init\n",
    "```\n",
    "\n",
    "Since the value on the right side is a `State`, the assignment matches\n",
    "up the index of the `State` with the columns of the `TimeFrame`; that\n",
    "is, it assigns the `s` value from `system.init` to the `s` column of\n",
    "`frame`, and likewise with `i` and `r`.\n",
    "\n",
    "Each time through the loop, we assign the `State` we get from `update_func` to the next row of `frame`.\n",
    "At the end, we return `frame`. \n",
    "\n",
    "We can call this version of `run_simulation` like this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "quick-fifty",
   "metadata": {},
   "outputs": [],
   "source": [
    "results = run_simulation(system, update_func)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "small-liability",
   "metadata": {},
   "source": [
    "Here are the first few rows of the results."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "appropriate-keyboard",
   "metadata": {},
   "outputs": [],
   "source": [
    "results.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "global-complement",
   "metadata": {},
   "source": [
    "The columns in the `TimeFrame` correspond to the state variables, `s`, `i`, and `r`.\n",
    "As with a `DataFrame`, we can use the dot operator to select columns\n",
    "from a `TimeFrame`, so we can plot the results like this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "listed-enough",
   "metadata": {},
   "outputs": [],
   "source": [
    "plot_results(results.s, results.i, results.r)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "statutory-begin",
   "metadata": {},
   "source": [
    "The results are the same as before, now in a more convenient form."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "neutral-replacement",
   "metadata": {},
   "source": [
    "## Summary\n",
    "\n",
    "This chapter presents an SIR model of infectious disease and two ways to collect the results, using several `TimeSeries` objects or a single `TimeFrame`.\n",
    "In the next chapter we'll use the model to explore the effect of immunization.\n",
    "\n",
    "But first you might want to work on these exercises."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "induced-tunnel",
   "metadata": {},
   "source": [
    "## Exercises\n",
    "\n",
    "This chapter is available as a Jupyter notebook where you can read the text, run the code, and work on the exercises. \n",
    "You can access the notebooks at <https://allendowney.github.io/ModSimPy/>."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "floral-remove",
   "metadata": {},
   "source": [
    "### Exercise 1  \n",
    "\n",
    "Suppose the time between contacts is 4 days and the recovery time is 5 days.  After 14 weeks, how many students, total, have been infected?\n",
    "\n",
    "Hint: what is the change in `S` between the beginning and the end of the simulation?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "parental-thunder",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "recovered-freeze",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "suited-spanking",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "derived-mauritius",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
